#ifndef CONTROLLERSERIALPORT_H
#define CONTROLLERSERIALPORT_H

#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QSettings>
#include <QDebug>

#include "sources/crc16.h"

class ControllerSerialPort : public QObject
{
    Q_OBJECT
public:
    explicit ControllerSerialPort(QObject *parent = nullptr);
    ~ControllerSerialPort();

public slots:
    void process();

    bool open();
    bool close();
    void openDoor();
    void closeDoor();

signals:
    void finished();
    void error(QString err);
    void connected(bool isConnect);

    void analyzeData(QByteArray data);

private slots:
    void readyRead();

private:
    QSerialPort *serialPort;

    bool isReadHalf;
    QByteArray readHalfBuffer;
};

#endif // CONTROLLERSERIALPORT_H
